import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core';

@Directive({
  selector: '[ktUnless]' 
})
export class UnlessDirective {
  private hasView = false;
  @Input()
  set ketUnless(bool:boolean) {
    if (!bool && !this.hasView) {
      this.viewContentRef.createEmbeddedView(this.templateRef);
      this.hasView = true;
    }else if (bool && this.hasView){
      this.viewContentRef.clear();
      this.hasView = false; 
    }
  }
  constructor(private templateRef:TemplateRef<any>, private viewContentRef:ViewContainerRef) { }

}
